InstallationGUI.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. function varargout = InstallationGUI(varargin)
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. % Configures toolbox paths for pipeline and installs fixes. %
  4. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  5. % Copyright (C) 2013-2014, Michael J. Cheung
  6. %
  7. % This file is a part of the MEG & PLS Pipeline (MEGPLS). For more
  8. % details, see the documentation included with the software package.
  9. %
  10. % MEGPLS is free software: you can redistribute it and/or modify it under
  11. % the terms of the GNU General Public License version 2 as published by
  12. % the Free Software Foundation. This program is distributed in the hope
  13. % that it will be useful, but WITHOUT ANY WARRANTY; without even the
  14. % implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. % See the GNU General Public License for more details.
  16. %
  17. % You should have received a copy of the GNU General Public License along
  18. % with this program. If not, you can download the license here:
  19. % <http://www.gnu.org/licenses/old-licenses/gpl-2.0>.
  20. % Last Modified by GUIDE v2.5 26-Feb-2014 21:48:15
  21. % Begin initialization code - DO NOT EDIT
  22. gui_Singleton = 1;
  23. gui_State = struct('gui_Name', mfilename, ...
  24. 'gui_Singleton', gui_Singleton, ...
  25. 'gui_OpeningFcn', @InstallationGUI_OpeningFcn, ...
  26. 'gui_OutputFcn', @InstallationGUI_OutputFcn, ...
  27. 'gui_LayoutFcn', [] , ...
  28. 'gui_Callback', []);
  29. if nargin && ischar(varargin{1})
  30. gui_State.gui_Callback = str2func(varargin{1});
  31. end
  32. if nargout
  33. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  34. else
  35. gui_mainfcn(gui_State, varargin{:});
  36. end
  37. % End initialization code - DO NOT EDIT
  38. %--- Executes just before InstallationGUI is made visible. ---%
  39. %---------------------------------------------------------%
  40. function InstallationGUI_OpeningFcn(hObject, eventdata, handles, varargin)
  41. % This function has no output args, see OutputFcn.
  42. % hObject handle to figure
  43. % eventdata reserved - to be defined in a future version of MATLAB
  44. % handles structure with handles and user data (see GUIDATA)
  45. % varargin command line arguments to InstallationGUI (see VARARGIN)
  46. % Choose default command line output for InstallationGUI
  47. handles.output = hObject;
  48. % Update handles structure
  49. guidata(hObject, handles);
  50. % Get pipeline run directory:
  51. [PipelineDir, ~, ~] = fileparts(which('InstallationGUI.m'));
  52. handles.PipelineDir = PipelineDir;
  53. % Initialize variables:
  54. if exist([PipelineDir,'/ToolboxPaths.mat'], 'file')
  55. ToolboxPaths = load([PipelineDir,'/ToolboxPaths.mat']);
  56. handles.paths.Fieldtrip = ToolboxPaths.paths.Fieldtrip;
  57. handles.paths.SPM = ToolboxPaths.paths.SPM;
  58. handles.paths.AFNIMatlab = ToolboxPaths.paths.AFNIMatlab;
  59. set(handles.TextboxFieldtripPath, 'String', handles.paths.Fieldtrip);
  60. set(handles.TextboxSPMPath, 'String', handles.paths.SPM);
  61. set(handles.TextboxAFNIMatlabPath, 'String', handles.paths.AFNIMatlab);
  62. else
  63. handles.paths.Fieldtrip = [];
  64. handles.paths.SPM = [];
  65. handles.paths.AFNIMatlab = [];
  66. end
  67. % Save handles:
  68. guidata(hObject, handles);
  69. % UIWAIT makes InstallationGUI wait for user response (see UIRESUME)
  70. % uiwait(handles.figure1);
  71. %--- Outputs from this function are returned to the command line. ---%
  72. %--------------------------------------------------------------------%
  73. function varargout = InstallationGUI_OutputFcn(hObject, eventdata, handles)
  74. % varargout cell array for returning output args (see VARARGOUT);
  75. % hObject handle to figure
  76. % eventdata reserved - to be defined in a future version of MATLAB
  77. % handles structure with handles and user data (see GUIDATA)
  78. % Get default command line output from handles structure
  79. varargout{1} = handles.output;
  80. %======================================%
  81. % FUNCTIONS FOR SETTING TOOLBOX PATHS: %
  82. %======================================%
  83. %--- Executes on button press in ButtonFieldtripPath. ---%
  84. %--------------------------------------------------------%
  85. function ButtonFieldtripPath_Callback(hObject, eventdata, handles)
  86. SelectedPath = uigetdir(pwd, 'Specify Fieldtrip toolbox directory:');
  87. if SelectedPath == 0
  88. return; % If user cancels
  89. end
  90. % Check if selected path is Fieldtrip toolbox:
  91. if ~exist([SelectedPath,'/ft_defaults.m'], 'file')
  92. ErrMsg = {'ERROR:';
  93. 'Selected directory does not seem to be Fieldtrip toolbox.';
  94. 'Cannot find "ft_defaults.m" function in target location.'};
  95. msgbox(ErrMsg, 'Error:');
  96. return;
  97. end
  98. % Import required fieldtrip private functions:
  99. ImportFcnDir = [handles.PipelineDir,'/MEGPLS_COMPONENTS/FieldtripPrivate'];
  100. if ~exist(ImportFcnDir, 'dir')
  101. status = mkdir(ImportFcnDir);
  102. if status == 0
  103. msgbox('Error: Failed to create folder in pipeline directory.')
  104. return;
  105. end
  106. end
  107. if exist([ImportFcnDir,'/parameterselection.m'], 'file');
  108. delete([ImportFcnDir,'/parameterselection.m']);
  109. end
  110. if exist([ImportFcnDir,'/align_ijk2xyz.m'], 'file');
  111. delete([ImportFcnDir,'/align_ijk2xyz.m']);
  112. end
  113. status1 = copyfile([SelectedPath,'/private/parameterselection.m'], [ImportFcnDir,'/'], 'f');
  114. status2 = copyfile([SelectedPath,'/private/align_ijk2xyz.m'], [ImportFcnDir,'/'], 'f');
  115. if status1 == 0 || status2 == 0
  116. msgbox('Error: Failed to import Fieldtrip private functions.')
  117. return;
  118. end
  119. % Set fieldtrip path:
  120. handles.paths.Fieldtrip = SelectedPath;
  121. set(handles.TextboxFieldtripPath, 'String', handles.paths.Fieldtrip);
  122. % Save handles:
  123. guidata(hObject, handles);
  124. %--- Textbox to display selected Fieldtrip path: ---%
  125. %---------------------------------------------------%
  126. function TextboxFieldtripPath_Callback(hObject, eventdata, handles)
  127. EnteredText = get(handles.TextboxFieldtripPath, 'String');
  128. if ~isequal(EnteredText, handles.paths.Fieldtrip);
  129. set(handles.TextboxFieldtripPath, 'String', handles.paths.Fieldtrip);
  130. msgbox('Note: Use button to change Fieldtrip path.')
  131. end
  132. %--- Executes on button press in ButtonSPMPath. ---%
  133. %--------------------------------------------------%
  134. function ButtonSPMPath_Callback(hObject, eventdata, handles)
  135. SelectedPath = uigetdir(pwd, 'Specify SPM8 toolbox directory:');
  136. if SelectedPath == 0
  137. return; % If user cancels
  138. end
  139. % Check if selected path is SPM toolbox:
  140. if ~exist([SelectedPath,'/spm_get_defaults.m'], 'file')
  141. ErrMsg = {'ERROR:';
  142. 'Selected directory does not seem to be SPM8 toolbox.';
  143. 'Cannot find "spm_get_defaults.m" function in target location.'};
  144. msgbox(ErrMsg, 'Error:');
  145. return;
  146. end
  147. % Set SPM path:
  148. handles.paths.SPM = SelectedPath;
  149. set(handles.TextboxSPMPath, 'String', handles.paths.SPM);
  150. % Save handles:
  151. guidata(hObject, handles);
  152. %--- Textbox to display selected SPM path: ---%
  153. %---------------------------------------------%
  154. function TextboxSPMPath_Callback(hObject, eventdata, handles)
  155. EnteredText = get(handles.TextboxSPMPath, 'String');
  156. if ~isequal(EnteredText, handles.paths.SPM);
  157. set(handles.TextboxSPMPath, 'String', handles.paths.SPM);
  158. msgbox('Note: Use button to change SPM path.')
  159. end
  160. %--- Executes on button press in ButtonAFNIMatlabPath. ---%
  161. %---------------------------------------------------------%
  162. function ButtonAFNIMatlabPath_Callback(hObject, eventdata, handles)
  163. SelectedPath = uigetdir(pwd, 'Specify AFNI-Matlab toolbox directory:');
  164. if SelectedPath == 0
  165. return; % If user cancels
  166. end
  167. % Check if selected path is AFNI-Matlab toolbox:
  168. if ~exist([SelectedPath,'/BrikLoad.m'], 'file')
  169. ErrMsg = {'ERROR:';
  170. 'Selected directory does not seem to be AFNI-Matlab toolbox.';
  171. 'Cannot find "BrikLoad.m" function in target location.'};
  172. msgbox(ErrMsg, 'Error:');
  173. return;
  174. end
  175. % Set AFNI-Matlab path:
  176. handles.paths.AFNIMatlab = SelectedPath;
  177. set(handles.TextboxAFNIMatlabPath, 'String', handles.paths.AFNIMatlab);
  178. % Save handles:
  179. guidata(hObject, handles);
  180. %--- Textbox to display selected AFNI-Matlab path: ---%
  181. %-----------------------------------------------------%
  182. function TextboxAFNIMatlabPath_Callback(hObject, eventdata, handles)
  183. EnteredText = get(handles.TextboxAFNIMatlabPath, 'String');
  184. if ~isequal(EnteredText, handles.paths.AFNIMatlab);
  185. set(handles.TextboxAFNIMatlabPath, 'String', handles.paths.AFNIMatlab);
  186. msgbox('Note: Use button to change AFNI-Matlab path.')
  187. end
  188. %--- Executes on button press in ButtonSaveSettings. ---%
  189. %-------------------------------------------------------%
  190. function ButtonSaveSettings_Callback(hObject, eventdata, handles)
  191. if isempty(handles.paths.Fieldtrip)
  192. msgbox('Warning: Fieldtrip path has not been set.', 'Warning:');
  193. return;
  194. end
  195. if isempty(handles.paths.SPM)
  196. msgbox('Warning: SPM path has not been set.', 'Warning:');
  197. return;
  198. end
  199. if isempty(handles.paths.AFNIMatlab)
  200. msgbox('Warning: AFNI-Matlab path has not been set.', 'Warning:');
  201. return;
  202. end
  203. % Install fixes:
  204. Success = MEGPLS_Install_Fixes(handles);
  205. if Success == 0
  206. return;
  207. end
  208. % Remove existing .mat:
  209. if exist([handles.PipelineDir,'/ToolboxPaths.mat'], 'file')
  210. delete([handles.PipelineDir,'/ToolboxPaths.mat']);
  211. if exist([handles.PipelineDir,'/ToolboxPaths.mat'], 'file')
  212. msgbox('Error: Failed to remove previous ToolboxPaths.mat for overwrite.', 'Error:')
  213. return;
  214. end
  215. end
  216. % Save paths to .mat:
  217. paths = handles.paths;
  218. save([handles.PipelineDir,'/ToolboxPaths.mat'], 'paths');
  219. % Addpaths:
  220. addpath(genpath(handles.PipelineDir));
  221. rmpath([handles.PipelineDir,'/DEFAULT_SETTINGS']); % Only want to call the ones in AnalysisID
  222. rmpath([handles.PipelineDir,'/TEMPORARY_FIXES']); % Want to call from Fieldtrip toolbox
  223. addpath([paths.Fieldtrip,'/']);
  224. ft_defaults;
  225. addpath([paths.SPM,'/']);
  226. addpath([paths.AFNIMatlab,'/']);
  227. % Feedback:
  228. if exist([handles.PipelineDir,'/ToolboxPaths.mat'], 'file')
  229. msgbox('Toolbox paths successfully saved.');
  230. end
  231. %--- Executes on button press in ButtonUninstallFixes. ---%
  232. %---------------------------------------------------------%
  233. function ButtonUninstallFixes_Callback(hObject, eventdata, handles)
  234. Success = MEGPLS_Uninstall_Fixes(handles);
  235. if Success == 0
  236. return;
  237. else
  238. msgbox('MEGPLS compatibility fixes successfully uninstalled.');
  239. end
  240. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  241. % FUNCTIONS FOR MEGPLS COMPATIBILITY FIXES: %
  242. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  243. %--- Installs compatibility fixes: ---%
  244. %-------------------------------------%
  245. function Success = MEGPLS_Install_Fixes(InputHandles)
  246. handles = InputHandles;
  247. paths = handles.paths;
  248. InstallErrMsg = {'Error:'; '';
  249. 'Failed to apply FieldTrip compatibility patch for [MEG]PLS pipeline.';
  250. 'Ensure you have read/write permissions to Fieldtrip and [MEG]PLS folders.';
  251. 'For more details, see README file in "TEMPORARY_FIXES" folder.'};
  252. FixBackupFolder = [paths.Fieldtrip,'/MEGPLS_INSTALL_BACKUP'];
  253. if ~exist(FixBackupFolder, 'dir')
  254. Status = mkdir(FixBackupFolder);
  255. if Status == 0
  256. msgbox(InstallErrMsg, 'Error:');
  257. Success = 0;
  258. return;
  259. end
  260. end
  261. % Apply temporary "warning_once" fix (See readme in "TEMPORARY_FIXES" folder):
  262. % Bug in newer version of FT "warning_once.m" that occurs when calling from MATLAB GUIDE.
  263. % Link: http://mailman.science.ru.nl/pipermail/fieldtrip/2013-August/006889.html
  264. % Backup original file:
  265. if ~exist([FixBackupFolder,'/warning_once.m'], 'file')
  266. TargetFile = [paths.Fieldtrip,'/private/warning_once.m'];
  267. if ~exist(TargetFile, 'file')
  268. msgbox('Error: Failed to find original "warning_once.m" file.', 'Error:')
  269. msgbox(InstallErrMsg, 'Error:')
  270. Success = 0;
  271. return;
  272. end
  273. MakeBackup = copyfile(TargetFile, [FixBackupFolder,'/'], 'f');
  274. if MakeBackup == 0
  275. msgbox('Error: Failed to create backup of original "warning_once.m" file.', 'Error:')
  276. msgbox(InstallErrMsg, 'Error:')
  277. Success = 0;
  278. return;
  279. end
  280. end
  281. % Apply fixed files (overwrite if needed):
  282. FixedFile = [handles.PipelineDir,'/TEMPORARY_FIXES/warning_once_20130211.m'];
  283. if exist([paths.Fieldtrip,'/private/warning_once.m'], 'file')
  284. delete([paths.Fieldtrip,'/private/warning_once.m']);
  285. if exist([paths.Fieldtrip,'/private/warning_once.m'], 'file')
  286. msgbox('Error: Failed to remove previous "warning_once.m" files for overwrite.', 'Error:')
  287. msgbox(InstallErrMsg, 'Error:')
  288. Success = 0;
  289. return;
  290. end
  291. Copy1 = copyfile(FixedFile, [paths.Fieldtrip,'/private/warning_once.m'], 'f');
  292. else
  293. Copy1 = 1;
  294. end
  295. if exist([paths.Fieldtrip,'/utilities/private/warning_once.m'], 'file')
  296. delete([paths.Fieldtrip,'/utilities/private/warning_once.m']);
  297. if exist([paths.Fieldtrip,'/utilities/private/warning_once.m'], 'file')
  298. msgbox('Error: Failed to remove previous "warning_once.m" files for overwrite.', 'Error:')
  299. msgbox(InstallErrMsg, 'Error:')
  300. Success = 0;
  301. return;
  302. end
  303. Copy2 = copyfile(FixedFile, [paths.Fieldtrip,'/utilities/private/warning_once.m'], 'f');
  304. else
  305. Copy2 = 1;
  306. end
  307. if exist([paths.Fieldtrip,'/specest/private/warning_once.m'], 'file')
  308. delete([paths.Fieldtrip,'/specest/private/warning_once.m']);
  309. if exist([paths.Fieldtrip,'/specest/private/warning_once.m'], 'file')
  310. msgbox('Error: Failed to remove previous "warning_once.m" files for overwrite.', 'Error:')
  311. msgbox(InstallErrMsg, 'Error:')
  312. Success = 0;
  313. return;
  314. end
  315. Copy3 = copyfile(FixedFile, [paths.Fieldtrip,'/specest/private/warning_once.m'], 'f');
  316. else
  317. Copy3 = 1;
  318. end
  319. if Copy1 == 0 || Copy2 == 0 || Copy3 == 0
  320. msgbox(InstallErrMsg, 'Error:');
  321. Success = 0;
  322. return;
  323. end
  324. % Apply temporary "ft_postamble_history" fix (See readme in "TEMPORARY_FIXES" folder):
  325. % Bug in newer version of FT "warning_once.m" that occurs when calling from MATLAB GUIDE.
  326. % Link: http://mailman.science.ru.nl/pipermail/fieldtrip/2013-August/006889.html
  327. % Backup original file:
  328. if ~exist([FixBackupFolder,'/ft_postamble_history.m'], 'file')
  329. TargetFile = [paths.Fieldtrip,'/utilities/private/ft_postamble_history.m'];
  330. if ~exist(TargetFile, 'file')
  331. msgbox('Error: Failed to find original "ft_postamble_history.m" file.', 'Error:')
  332. msgbox(InstallErrMsg, 'Error:')
  333. Success = 0;
  334. return;
  335. end
  336. MakeBackup = copyfile(TargetFile, [FixBackupFolder,'/'], 'f');
  337. if MakeBackup == 0
  338. msgbox(InstallErrMsg, 'Error:')
  339. Success = 0;
  340. return;
  341. end
  342. end
  343. % Apply fixed files (overwrite if needed):
  344. FixedFile = [handles.PipelineDir,'/TEMPORARY_FIXES/ft_postamble_history_20130211.m'];
  345. if exist([paths.Fieldtrip,'/utilities/private/ft_postamble_history.m'], 'file')
  346. delete([paths.Fieldtrip,'/utilities/private/ft_postamble_history.m']);
  347. if exist([paths.Fieldtrip,'/utilities/private/ft_postamble_history.m'], 'file')
  348. msgbox('Error: Failed to remove previous "ft_postamble_history.m" for overwrite.', 'Error:')
  349. msgbox(InstallErrMsg, 'Error:')
  350. Success = 0;
  351. return;
  352. end
  353. end
  354. Copy = copyfile(FixedFile, ...
  355. [paths.Fieldtrip,'/utilities/private/ft_postamble_history.m'], 'f');
  356. if Copy == 0
  357. msgbox(InstallErrMsg, 'Error:');
  358. Success = 0;
  359. return;
  360. end
  361. % Add legend functionality to "ft_singleplotER" function.
  362. % (So children of interactive multiplot have legends applied).
  363. if ~exist([FixBackupFolder,'/ft_singleplotER.m'], 'file')
  364. TargetFile = [paths.Fieldtrip,'/ft_singleplotER.m'];
  365. if ~exist(TargetFile, 'file')
  366. msgbox('Error: Failed to find original "ft_singleplotER.m" file.', 'Error:')
  367. msgbox(InstallErrMsg, 'Error:')
  368. Success = 0;
  369. return;
  370. end
  371. MakeBackup = copyfile(TargetFile, [FixBackupFolder,'/'], 'f');
  372. if MakeBackup == 0
  373. msgbox(InstallErrMsg, 'Error:')
  374. Success = 0;
  375. return;
  376. end
  377. % Add fix to file once:
  378. TempPathFT = strrep(paths.Fieldtrip, ' ', '\ '); % Replace spaces with "\ " for unix.
  379. system(['sed -i "/ft_postamble previous/ a\ \n'...
  380. 'if isfield(cfg, ''legend'')\n'...
  381. ' if numel(cfg.legend) ~= Ndata\n'...
  382. ' disp(''Warning: # legend inputs does not match # datasets.'')\n'...
  383. ' end\n'...
  384. ' clickableLegend(cfg.legend, ''interpreter'', ''none'');\n'...
  385. 'end\n\n" ',TempPathFT,'/ft_singleplotER.m'])
  386. % SED function to add text after match:
  387. % Format: sed -i '/regexp-string-to-match/ a\ string-to-append' filename
  388. % Note: a\ option is used to append text after line of address match.
  389. end
  390. Success = 1;
  391. %--- Uninstalls compatibility fixes: ---%
  392. %---------------------------------------%
  393. function Success = MEGPLS_Uninstall_Fixes(InputHandles)
  394. handles = InputHandles;
  395. paths = handles.paths;
  396. UninstallErrMsg = {'Error:'; '';
  397. 'Failed to uninstall compatibility fixes for MEGPLS pipeline.';
  398. 'Check permissions on Fieldtrip and MEGPLS pipeline folders.';
  399. 'See README file in "TEMPORARY_FIXES" folder.'};
  400. FixBackupFolder = [paths.Fieldtrip,'/MEGPLS_INSTALL_BACKUP'];
  401. % Uninstall "warning_once.m" fix:
  402. BackupFile = [FixBackupFolder,'/warning_once.m'];
  403. if exist(BackupFile, 'file')
  404. if exist([paths.Fieldtrip,'/private/warning_once.m'], 'file')
  405. delete([paths.Fieldtrip,'/private/warning_once.m']);
  406. if exist([paths.Fieldtrip,'/private/warning_once.m'], 'file')
  407. msgbox('Error: Failed to remove "warning_once.m" files for uninstall.', 'Error:')
  408. msgbox(UninstallErrMsg, 'Error:')
  409. Success = 0;
  410. return;
  411. end
  412. Restore1 = copyfile(BackupFile, [paths.Fieldtrip,'/private/warning_once.m'], 'f');
  413. else
  414. Restore1 = 1;
  415. end
  416. if exist([paths.Fieldtrip,'/utilities/private/warning_once.m'], 'file')
  417. delete([paths.Fieldtrip,'/utilities/private/warning_once.m']);
  418. if exist([paths.Fieldtrip,'/utilities/private/warning_once.m'], 'file')
  419. msgbox('Error: Failed to remove "warning_once.m" files for uninstall.', 'Error:')
  420. msgbox(UninstallErrMsg, 'Error:')
  421. Success = 0;
  422. return;
  423. end
  424. Restore2 = copyfile(BackupFile, [paths.Fieldtrip,'/utilities/private/warning_once.m'], 'f');
  425. else
  426. Restore2 = 1;
  427. end
  428. if exist([paths.Fieldtrip,'/specest/private/warning_once.m'], 'file')
  429. delete([paths.Fieldtrip,'/specest/private/warning_once.m']);
  430. if exist([paths.Fieldtrip,'/specest/private/warning_once.m'], 'file')
  431. msgbox('Error: Failed to remove "warning_once.m" files for uninstall.', 'Error:')
  432. msgbox(UninstallErrMsg, 'Error:')
  433. Success = 0;
  434. return;
  435. end
  436. Restore3 = copyfile(BackupFile, [paths.Fieldtrip,'/specest/private/warning_once.m'], 'f');
  437. else
  438. Restore3 = 1;
  439. end
  440. if Restore1 == 0 || Restore2 == 0 || Restore3 == 0
  441. msgbox(UninstallErrMsg, 'Error:');
  442. Success = 0;
  443. return;
  444. end
  445. end
  446. % Uninstall "ft_postamble_history" fix:
  447. BackupFile = [FixBackupFolder,'/ft_postamble_history.m'];
  448. if exist(BackupFile, 'file')
  449. delete([paths.Fieldtrip,'/utilities/private/ft_postamble_history.m']);
  450. if exist([paths.Fieldtrip,'/utilities/private/ft_postamble_history.m'], 'file')
  451. msgbox('Error: Failed to remove "ft_postamble_history.m" files for uninstall.', 'Error')
  452. msgbox(UninstallErrMsg, 'Error:')
  453. Success = 0;
  454. return;
  455. end
  456. Restore = copyfile(BackupFile, ...
  457. [paths.Fieldtrip,'/utilities/private/ft_postamble_history.m'], 'f');
  458. if Restore == 0
  459. msgbox(UninstallErrMsg, 'Error:');
  460. Success = 0;
  461. return;
  462. end
  463. end
  464. % Uninstall "ft_singleplotER" legend modification:
  465. BackupFile = [FixBackupFolder,'/ft_singleplotER.m'];
  466. if exist(BackupFile, 'file')
  467. delete([paths.Fieldtrip,'/ft_singleplotER.m']);
  468. if exist([paths.Fieldtrip,'/ft_singleplotER.m'], 'file')
  469. msgbox('Error: Failed to remove "ft_singleplotER.m" file for uninstall.', 'Error:')
  470. msgbox(UninstallErrMsg, 'Error:')
  471. Success = 0;
  472. return;
  473. end
  474. Restore = copyfile(BackupFile, [paths.Fieldtrip,'/ft_singleplotER.m'], 'f');
  475. if Restore == 0
  476. msgbox(UninstallErrMsg, 'Error:');
  477. Success = 0;
  478. return;
  479. end
  480. end
  481. % Remove ToolboxPaths.mat file:
  482. ToolboxPathsFile = [handles.PipelineDir,'/ToolboxPaths.mat'];
  483. if exist(ToolboxPathsFile, 'file')
  484. delete(ToolboxPathsFile);
  485. if exist(ToolboxPathsFile, 'file')
  486. msgbox('Error: Failed to remove ToolboxPaths.mat file for uninstall.', 'Error:')
  487. return;
  488. end
  489. end
  490. if exist(FixBackupFolder, 'dir')
  491. rmdir(FixBackupFolder, 's');
  492. end
  493. Success = 1;
  494. %============================%
  495. % GUIDE CREATEGUI FUNCTIONS: %
  496. %============================%
  497. % --- Executes during object creation, after setting all properties.
  498. function TextboxFieldtripPath_CreateFcn(hObject, eventdata, handles)
  499. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  500. set(hObject,'BackgroundColor','white');
  501. end
  502. % --- Executes during object creation, after setting all properties.
  503. function TextboxSPMPath_CreateFcn(hObject, eventdata, handles)
  504. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  505. set(hObject,'BackgroundColor','white');
  506. end
  507. % --- Executes during object creation, after setting all properties.
  508. function TextboxAFNIMatlabPath_CreateFcn(hObject, eventdata, handles)
  509. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  510. set(hObject,'BackgroundColor','white');
  511. end